function ShowBanner(i,s){
	$("#img-box img").fadeOut(s);
	$("#img-box img:eq("+ i +")").fadeIn(s);
	$("#page li").removeClass("page-active");
	$("#page li:eq("+ i +")").addClass('page-active');
}

function SetTextCent(){
	var _width = $("#bottom-border h3").width();
	$("#bottom-border h3").css('margin-left',((276-_width)/2.8)+'px');
}
$(function(){
	
	SetTextCent();
	
	var leng = $("#img-box img").length;
	var speed = 1300;					//渐隐速度
	var timer = null;
	var index = 0;
	
	if($("#common-menu")){
		var k = $("#common-menu>li").length;
		//console.log("k======"+k);
		for(var i=0; i<k; i++){
			if($("#common-menu>li:eq("+ i +")").hasClass('menu-current')){
				//console.log("i ======= :"+i);
				index = i%leng;
			}
		}
	}
	
	var currentShow = index;
	ShowBanner(currentShow,speed);
	
	clearInterval(timer);
	timer = setInterval(AutoShowBanner,4000);
	
	function AutoShowBanner(){
		currentShow++;
		currentShow = currentShow%leng;
		console.log("currentShow:"+currentShow)
		ShowBanner(currentShow,speed);
	}
	
	$("#banner").mouseover(function(){ 
		clearInterval(timer); 
	});
	$("#banner").mouseout(function(){
		clearInterval(timer); 
		timer = setInterval(AutoShowBanner,4000);
	});
	
	$("#page li").each(function(i){
		$(this).click(function(){
			currentShow = i;
			ShowBanner(currentShow,speed);
		})
	})
})
